function Punkt(x, y)
{
  this.x = x;
  this.y = y;
  this.odległość = function()
  {
    return Math.sqrt(this.x * this.x + this.y * this.y);
  }
}

var punkt1 = new Punkt(1, 10);
var punkt2 = new Punkt(20, 30);
var d1 = punkt1.odległość();
var d2 = punkt2.odległość();

alert("punkt1.odległość = " + d1);
alert("punkt2.odległość = " + d2);
